<?php
namespace App\Http\Controllers\Usermanagement;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseApiController;
use App\Services\Usermanagement\UsermanagementService;

class UsermanagementController extends BaseApiController
{
    private $service;

    public function __construct(UsermanagementService $service)
    {
        //继承基类的构造方法
        parent::__construct();
        //依赖注入service
        $this->service = $service;
    }
    // 用户登入
    public function UserLogin(Request $request)
    {
        $rule=['phone' => 'required|size:11','password' => 'required|max:50'];
        if($error=$this->validate($rule,$request))
        {
            return $error;
        }
        //根据类型去查询
        $data=$request->post();

        return $this->service->UserLogin($data);
    }

    public function CheckToken(Request $request)
    {
        $rule=['token' => 'required'];
        if($error=$this->validate($rule,$request))
        {
            return $error;
        }
        $token=$request->get('token');

        return  $this->service->getToken($token);
    }

    public function add()
    {
        echo 123;
    }

}

